import axios from 'axios'
import config from '@/config'
import store from '@/store'

/**
 * 统计
 * 1. 总physical room, 总logical room, 今日订单数， 今日卖出金额
 * 2. 交易数据展示, 未来入住走向, 每日订单量走向
 * 3. 平均咨询, 平均订单, 平均金额, 平均订单信息量
 * 4. 房源分布， 房源类型
 * 5. 今日订单
 * @param host
 * @param cur_type
 * @returns {AxiosPromise}
 */

export function dashboard(host, cur_type = 'cny') {
    if (host) {
        let data = {host}
        if (cur_type) {
            data.kwargs = {'host_currency': cur_type}
        }
        return axios({
            method: 'post',
            url: config.serverURI + config.api.dashboard,
            data
        })
    }
    else {
        return axios({
            method: 'get',
            url: config.serverURI + config.api.dashboard
        })
    }
}

export function queryCurve(name, params) {
    return axios({
        method: 'post',
        url: config.serverURI + config.api.query_curve,
        data: {name, params}
    })
}

export function queryTable(name, subname, kwargs) {
    let data = {name}
    if (subname) {
        data.subname = subname
    }
    if (kwargs) {
        data.kwargs = kwargs
    }
    return axios({
        method: 'post',
        url: config.serverURI + config.api.query_table,
        data
    })
}
export function overview() {
    return axios({
        method: 'get',
        url: config.serverURI + config.api.overview
    })
}

export function orderAnalysis(data) {
    return axios({
        method: 'post',
        url: config.serverURI + config.api.big_data.order_analysis,
        data
    })
}